<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户中心-{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link rel="stylesheet" href="__STATIC__/css/index.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/css/security_set.css">
    <link rel="stylesheet" href="__STATIC__/css/btn.css">
<link rel="stylesheet" href="__STATIC__/css/user.css" type="text/css">
    <script src="__STATIC__/js/jquery-1.10.2.min.js"></script>
    <script src="__STATIC__/js/slider.js"></script>
</head>
<body>
<include file="Public/header" />

<div id="user_container">
	<div id="user_login">
		<div class="wel-log">验证身份</div>
		
            
			  <div class="login-x">
                <div>
                    <table class="pa-10-0" width="100%" border="0" cellspacing="0" cellpadding="0">

                        <tr>
                            <td><select id="verify-type-selector" style=" width: 523px;    border: 1px solid #DCDCDC; color:#757575; font-size: 14px; height: 52px;display: none;">
	<if condition="strstr($_POST['username'],'@')">
		<option value="email" selected alias-value="2">邮箱验证</option>
	<else / >
		<option value="phone" selected alias-value="1">手机验证</option>
	</if>
</select>
                            </td>
                        </tr>
                       
                       <if condition="$userinfo['mobile'] neq ''">
                        <tr>
                            <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证手机号码：{$userinfo.mobile}" readonly/>
                            </td>
                        </tr>
                        </if>
                       
                       <if condition="$userinfo['email'] neq ''">
                        <tr>
                            <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证邮箱：{$userinfo.email}" readonly/>
                            </td>
                        </tr></if>
                       
                        <tr>
                            <td>
                                <input class="zc-text zc_code" type="text" name="tpcode" id="tpcode" placeholder="{$Think.lang.logincode}"/>
                                <input type="button" class="" style="width: 105px;height:52px;margin-top:0; border:none; background:#000; float:right; color:#fff;" id="sendSms" onclick="sendcode(this)" value="获取验证码">
                            </td>
                        </tr>
                        
                        <tr>
                            <td><input type="button" class="login" id="fx_next" onclick="setpwd()" value="下一步"><br ><br ><br ><br ><br ><br ></td>
                        </tr>
                    </table>
                </div>
            </div>
	</div>
</div>


<input type="hidden" id="username" value="{$userinfo.username}"> 
<div style="clear: both;"></div>
<include file="Public/footer" />
<script>
function sendcode(o){
	$.ajax({
		url:'/index.php?m=Home&c=User&a=send_validate_code&t='+Math.random(),
		type:'post',
		dataType:'json',
		data:{type:$('#verify-type-selector').val(),send:$('#username').val()},
		success:function(res){
			if(res.status==1){
				timer(o);
			}else{
				$.artTip(res.msg, 800);
			}
		}
	})
}

var wait=180;
function timer(o) { 
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon-warn');
	//$('span[data-tips-for="tpcode"]').find('.txt').empty();
    if (wait == 0) {  
        o.removeAttribute("disabled");            
        o.value="获取验证码";  
        wait = 180;  
    } else {  
        o.setAttribute("disabled", true);  
        o.value="重新发送(" + wait + ")";  
        wait--;  
        setTimeout(function() {  
          timer(o)  
        }, 1000)  
    }  
}

var is_check = false;
function checkcode(){
	var tpcode = $('#tpcode').val();
	//$('span[data-tips-for="tpcode"]').css('display','inline');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-warn');
	if(tpcode == ''){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不能为空');
		
				$.artTip('验证码不能为空', 800);
		return;
	}
	if(tpcode.length != 4){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不正确');
				$.artTip('验证码不正确', 800);
		return;
	}
	
	$.ajax({
		url:'/index.php?m=Home&c=User&a=check_validate_code&t='+Math.random(),
		type:'post',
		dataType:'json',
		data:{code:tpcode,send:$('#username').val()},
		success:function(res){
			if(res.status==1){
				is_check = true;
				//$('span[data-tips-for="tpcode"]').css('display','inline');
				//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon-warn');
				//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-loss');
				//$('span[data-tips-for="tpcode"]').find('.txt').empty();
				window.location.href='/index.php?m=Home&c=User&a=set_pwd&t='+Math.random();
			}else{
				//$('span[data-tips-for="tpcode"]').find('.txt').empty().html(res.msg);
				$.artTip(res.msg, 800);
				//alert('验证码未验证通过');
				return false;				
			}
		}
	})
}

function setpwd(){
	var tpcode = $('#tpcode').val();
	//$('span[data-tips-for="tpcode"]').css('display','inline');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-warn');
	if(tpcode == ''){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不能为空');
		$.artTip('验证码不能为空', 800);
		return;
	}
	if(tpcode.length != 4){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不正确');
		$.artTip('验证码不正确', 800);
		return;
	}
	
	checkcode();
 
}
</script>
</body>
</html>	